<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background: url('https://cdn.pixabay.com/photo/2018/08/14/13/23/ocean-3605547_1280.jpg') no-repeat;
            background-size: 100% 130%;
        }

        #login_box {
            width: 20%;
            height: 400px;
            background-color: #00000060;
            margin: auto;
            margin-top: 10%;
            text-align: center;
            border-radius: 10px;
            padding: 50px 50px;
        }

        h2 {
            color: #ffffff90;
            margin-top: 5%;
        }

        #input-box {
            margin-top: 5%;
        }

        span {
            color: #fff;
        }

        input {
            border: 0;
            width: 60%;
            font-size: 15px;
            color: #fff;
            background: transparent;
            border-bottom: 2px solid #fff;
            padding: 5px 10px;
            outline: none;
            margin-top: 10px;
        }

        button {
            margin-top: 10px;
            width: 60%;
            height: 30px;
            border-radius: 10px;
            border: 0;
            color: #fff;
            text-align: center;
            line-height: 30px;
            font-size: 15px;
            background-image: linear-gradient(to right, #30cfd0, #330867);
        }

        #sign_up {
            margin-top: 45%;
            margin-left: 60%;
        }

        a {
            color: #b94648;
        }
    </style>
    <script src="js/jquery-1.7.2.js"></script>
    <script>
        $(function(){
            let user={};
            $("#btn_login").click(function () {
                user.username = $("#username").val();
                user.password = $("#pwd").val();
                $.ajax({
                    type:"POST",
                    url:"/student/login",
                    data: JSON.stringify(user),
                    contentType:"application/json",
                    success: function(r){
                        if(r.ok){
                            if(r.result.userVO.roleType == 0){
                                window.location = "/courseMgr.html";
                            }else{
                                window.location = "/student/selectCourse.html";
                            }
                        }else{
                            alert(r.msg)
                        }
                    }
                });
            })

            $("#btn_reg").click(function () {
                window.location = "/register.html";
            });
        });
    </script>
</head>

<body>
<div id="login_box">
    <h2>用户登录</h2>
    <div id="input_box">
        <input type="text" placeholder="用户名" id="username">
    </div>
    <div class="input_box">
        <input type="password" placeholder="密码" id="pwd">
    </div>
    <button id="btn_login">登录</button><br>
    <a href="register.html">
        <button id="btn_reg">注册</button><br>
    </a>


</div>
</body>
</html>
